package org.sakai.controller;

import org.sakai.service.DiseaseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@RequestMapping("/disease")
public class DiseaseController {

    @Autowired
    private DiseaseService diseaseService;

    /**
     * 获取疾病列表（分页）
     */
    @GetMapping("/list")
    public Map<String, Object> getDiseaseList(
            @RequestParam(defaultValue = "1") int pageNum,
            @RequestParam(defaultValue = "10") int pageSize,
            @RequestParam(required = false) String keyword,
            @RequestParam(required = false) String isSpecialZone,
            @RequestParam(required = false) Long departmentId,
            @RequestParam(required = false) String sortBy,
            @RequestParam(required = false) String sortOrder) {
        
        return diseaseService.getDiseaseList(pageNum, pageSize, keyword, isSpecialZone, departmentId, sortBy, sortOrder);
    }

    /**
     * 获取疾病详情
     */
    @GetMapping("/{id}")
    public Map<String, Object> getDiseaseDetail(@PathVariable Long id) {
        return diseaseService.getDiseaseDetail(id);
    }

    /**
     * 搜索疾病
     */
    @GetMapping("/search")
    public Map<String, Object> searchDisease(@RequestParam String keyword) {
        return diseaseService.searchDisease(keyword);
    }
}
